package dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import entity.Employee;

public class EmployeeDao extends BaseDao{

	public boolean setPunishParam(Employee emp) {
		String sql = "update tb_employee set leaveParam="+emp.getLeaveParam()+",lateParam="+
	emp.getLateParam()+",absentParam="+emp.getAbsentParam()+",overtimeParam="+emp.getOvertimeParam()+" where id="+emp.getId();
		if(update(sql)) {
			return true;
		}else {
			return false;
		}
	}

	public Employee searchEmployeeById(int empId) {
		String sql = "select * from tb_employee where userId="+empId;
		ResultSet result = select(sql);
		try {
			while(result.next()) {
				Employee emp = new Employee();
				emp.setId(empId);
				emp.setUserId(result.getInt("userId"));
				emp.setWorkDate(result.getString("workDate"));
				emp.setPosition(result.getString("position"));
				emp.setLeaveParam(result.getDouble("leaveParam"));
				emp.setLateParam(result.getDouble("lateParam"));
				emp.setAbsentParam(result.getDouble("absentParam"));
				emp.setOvertimeParam(result.getDouble("overtimeParam"));
				return emp;
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
   
}
